// 运行时配置

// 全局初始化数据配置，用于 Layout 用户信息和权限初始化
// 更多信息见文档：https://umijs.org/docs/api/runtime-config#getinitialstate
export async function getInitialState(): Promise<{ name: string }> {
  return { name: '@umijs/max' };
}
const whites = ['/user/login', 'html']
export const layout = () => {
  return {
    title: '文档管理系统',
    logo: 'https://img.alicdn.com/tfs/TB1YHEpwUT1gK0jSZFhXXaAtVXa-28-27.svg',
    menu: {
      locale: false,
    },
    onPageChange: () => {
      // 如果没有登录，重定向到 login
      // if (!initialState?.currentUser && location.pathname !== loginPath) {
      //   history.push(loginPath);
      // }
      console.log('window.location.pathname ', window.location.pathname)
      if (!localStorage.getItem('isLogin') && (window.location.pathname !== '/user/login' && !window.location.pathname.includes('html'))) {
        window.location.href = '/user/login'; // 重定向到首页
      }
    },
  };
};
